import cv2


def img_show(name, img):
    """
        显示图片
        :param name: 窗口名字
        :param img: 图片对象
        :return: None
    """
    cv2.imshow(name, img)
    cv2.waitKey(0)
    cv2.destroyAllWindows()


cloud = cv2.imread('bg.jpg')
fish = cv2.imread('fish.jpg')

print('cloud is shape:', cloud.shape)
print('fish is shape:', fish.shape)

cloud_resize = cv2.resize(cloud, (474, 474))
print('cloud_resize is shape:', cloud_resize.shape)
img_show('cloud_resize', cloud_resize)

cloud_resize_ = cv2.resize(cloud, (0, 0), fx=1.2, fy=1)  # 不指定具体修改的大小 可以指定横和宽的比例
print('cloud_resize_ is shape:', cloud_resize_.shape)
img_show('cloud_resize_', cloud_resize_)

# R = AX1 + BX2 + b (A+B=1, A,B分别对应着X1,X2图像的权重, b亮度)
fusion_img = cv2.addWeighted(cloud_resize, 0.4, fish, 0.6, 0)
img_show('fusion_img', fusion_img)